﻿using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using MyCompanyName.AbpZeroTemplate.IRepositorys;
using MyCompanyName.AbpZeroTemplate.OperateCenter.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyCompanyName.AbpZeroTemplate.OperateCenter
{
    public class OperateCenterService : AbpZeroTemplateAppServiceBase, IOperateCenterService
    {
        private readonly IDailyReportRepository _dailyReportRepository;
        private readonly IMonthReportRepository _monthReportRepository;
        public OperateCenterService(IDailyReportRepository dailyReportRepository,
                            IMonthReportRepository monthReportRepository)
        {
            this._dailyReportRepository = dailyReportRepository;
            this._monthReportRepository = monthReportRepository;
        }

        /// <summary>
        /// 获得卡片日用量列表
        /// </summary>
        /// <returns></returns>
        public PagedResultDto<DailyReportDto> GetOperateDailyReportDtoList(string OperateDailyReportName, int PageSize, int PageNumber)
        {
            var obj = _dailyReportRepository.GetAll();
            
            //判断逻辑

            //获取总数
            var dataCount = obj.Count();

            //默认的分页方式
            var dataList = obj.Where(m => m.UCCID.Contains(OperateDailyReportName))
                              .OrderByDescending(t => t.CreationTime)
                              .Skip(PageSize * (PageNumber - 1)).Take(PageSize).ToList();
            return new PagedResultDto<DailyReportDto>(dataCount, dataList.MapTo<List<DailyReportDto>>());
        }

        /// <summary>
        /// 获得卡片月用量列表
        /// </summary>
        /// <returns></returns>
        public PagedResultDto<MonthReportDto> GetOperateMonthReportDtoList(string OperateMonthReportName, int PageSize, int PageNumber)
        {
            var obj = _monthReportRepository.GetAll();
            
            //判断逻辑

            //获取总数
            var dataCount = obj.Count();

            //默认的分页方式
            var dataList = obj.Where(m => m.UCCID.Contains(OperateMonthReportName))
                              .OrderByDescending(t => t.CreationTime)
                              .Skip(PageSize * (PageNumber - 1)).Take(PageSize).ToList();
            return new PagedResultDto<MonthReportDto>(dataCount, dataList.MapTo<List<MonthReportDto>>());
        }
    }
}
